<template>
  <div class="home">
    <el-container>
      <el-header>
        <span>宏烨找房后台管理系统</span>
      </el-header>
      <el-container>
        <el-aside :width="isCollapse ? '64px' : '200px'">
          <p @click="show" v-if="isCollapse" class="change">展开</p>
          <p @click="show" v-else class="change">收起</p>
          <el-menu
            class="el-menu-vertical-demo"
            @open="handleOpen"
            @close="handleClose"
            :collapse="isCollapse"
            background-color="rgb(0, 22, 31)"
            text-color="white"
            router
          >
            <el-menu-item :index="v.path" v-for="(v, i) in route" :key="i">
              <i :class="v.icon"></i>
              <span slot="title">{{ v.title }}</span>
            </el-menu-item>
          </el-menu>
        </el-aside>
        <el-main>
          <router-view></router-view>
        </el-main>
      </el-container>
    </el-container>
  </div>
</template>

<script>
import { mapState } from "vuex";
import getAuth from "../util/auth/getAuth";
export default {
  data() {
    return {
      route: [],
      isCollapse: false
    };
  },
  computed: {
    ...mapState(["auth"])
  },
  methods: {
    show() {
      this.isCollapse = !this.isCollapse;
    },
    handleOpen(key, keyPath) {
      console.log(key, keyPath);
    },
    handleClose(key, keyPath) {
      console.log(key, keyPath);
    }
  },
  created() {
    console.log(this.auth);
    this.route = getAuth();
    console.log(this.route);
  },
  destory() {
    this.route = getAuth();
  }
};
</script>

<style scoped lang='scss'>
.home {
  width: 100%;
  height: 100%;
}
.el-header {
  // background-color: #b3c0d1;
  // background: #409EFF;
  // display: flex;
  // align-items: center;
  // font-size: 30px;
  // color: white;
  background-color: rgb(76, 149, 233);
  display: flex;
  justify-content: space-between;
  padding-left: 10px;
  align-items: center;
  color: #fff;
}

.el-header span {
  font-size: 23px;
  font-weight: bold;
}
.el-aside {
  max-width: 200px;
  background: rgb(0, 22, 31);
  color: #333;
}

.el-main {
  background-color: #e9eef3;
  color: #333;
}
body > .el-container {
  margin-bottom: 40px;
}

.el-container:nth-child(5) .el-aside,
.el-container:nth-child(6) .el-aside {
  line-height: 260px;
}

.el-container:nth-child(7) .el-aside {
  line-height: 320px;
}
.el-col-12 {
  width: 100%;
}
.open {
  width: 100px;
  height: 40px;
  text-align: center;
  line-height: 40px;
}
.el-menu {
  border: none !important;
}
.el-menu-vertical-demo:not(.el-menu--collapse) {
  width: 200px;
  min-height: 100px;
}
.change {
  width: 100%;
  color: white;
  text-align: center;
}
.el-container {
  width: 100%;
  height: 100%;
}

</style>